! function (t) {
    function i(s) {
        if (e[s]) return e[s].exports;
        var n = e[s] = {
            exports: {},
            id: s,
            loaded: !1
        };
        return t[s].call(n.exports, n, n.exports, i), n.loaded = !0, n.exports
    }
    var e = {};
    return i.m = t, i.c = e, i.p = "./", i(0)
}([function (t, i, e) {
    e(1)
}, function (t, i) {
    Vue.component("pop-buy-component", {
        template: '' +
        '<div class="pop-panel" id="buy" v-bind:class="{\'show\':this.show}">' +
            '<div class="pop-box">' +
                '<div class="pop-title"><span class="title-red" v-if="swl==1">看涨</span><span class="title-green" v-if="swl==2">看跌</span><div style="float:right;margin-right:15px;color:#000000;"><span>{!type_name!}：</span><span class="text-gray" v-if="dir==0">{!c_money!}  </span><span style="color:#14c52c" v-if="dir==2">{!c_money!} ▼ </span><span class="text-red" v-if="dir==1">{!c_money!} ▲ </span></div></div>' +
                '<div class="pop-content pop_buy">' +
                    '<div class="btn-gards" >' +
                        '<div class="mask" v-if="!is_momney"></div>' +
                        '<div class="btn-row l_4" ><span style="float:left;color:#939393;font-size:12px;margin-top:10px;width:19%;line-height:30px;text-align:center;">合约金额</span><a @click="select_money(item)" v-bind:class="{\'active\':this.buy_money==item}" v-if="item!=-1" v-for="item in btns">{!item!}</a></div>' +
                    '</div>' +
                    '<div class="btn-gards" >' +
                        '<div class="mask" v-if="!is_momney"></div>' +
                        '<div class="btn-row l_4" ><span style="float:left;color:#939393;font-size:12px;margin-top:10px;width:19%;line-height:30px;text-align:center;">止损/止盈</span><a @click="select_contact(item.contact)" v-bind:class="{\'active\':this.buy_contact==item.contact}" v-if="item!=-1" v-for="item in contact_btns">{!item.contact!}</a></div>' +
                    '</div>' +
                    '<div class="btn-gards" >' +
                        '<div class="btn-row l_4" ><span style="float:left;color:#939393;font-size:12px;margin-top:10px;width:19%;line-height:30px;text-align:center;">数量</span><a style="width:50px;" @click="subtract()">-</a><span style="float:left;font-size:16px;color:#e63335;margin-top:10px;line-height:30px;text-align:center;width:30px;">{!num!}</span><a style="width:50px;" @click="augment()">+</a><span style="float:right;color:#a69292;line-height:30px;margin-top:10px;margin-right:20px;font-size:12px;">最大下单数{!max_num!}手</span></div>' +
                    '</div>' +
                    '<div class="select-gards" >' +
                        '<div style="margin-top:10px;" v-if="ticket_list.length>0">使用优惠券</div>' +
                        '<div class="select-row l_3">' +
                            '<template v-for="item in ticket_list">' +
                                '<div v-bind:class="{\'active\':ticket_index==$index,\'number\':item.can_user_num>1,\'disabled\':item.can_user_num==0}">' +
                                    '<div>' +
                                        '<a @click="select_ticket($index)" >{!item.name!}<small>{!item.money!}元 {!item.totals!}张</small><span  v-if="item.can_user_num>1 && ticket_index==$index">{!item.can_user_num!}</span></a>' +
                                        '<input v-if="item.can_user_num>1 " @input="ticket_change(item.can_user_num)" type="number" v-model="ticket_number" class="ticket_number"/>' +
                                    '</div>' +
                                '</div>' +
                            '</template>' +
                        '</div>' +
                    '</div>' +
                    '<div class="footer">' +
                        '<a class="btn btn-primary close" @click="close()">{!close_btn_str!}</a>' +
                        '<template  v-if="swl==1">' +
                            '<a class="btn btn-red define" style="margin-right:1%" @click="define()" v-bind:class="{\'bind\':!buy_btn_act}">{!buy_btn_str!}</a>' +
                        '</template>' +
                        '<template v-else>' +
                            '<a class="btn btn-green define" style="margin-right:1%" @click="define()" v-bind:class="{\'bind\':!buy_btn_act}">{!buy_btn_str!}</a>' +
                        '</template>' +
                    '</div>' +
                    '<div style="color:#a6a6a6;margin:5px 0 3px 0;font-size:12px;">{{{info}}}</div>' +
                    '<div class="prompt_box"><div class="prompt" v-bind:class="{\'show\':prompts!=\'\',\'hide\':prompts==\'\'}">{{{prompts}}}</div></div>' +
                '</div>' +
            '</div>' +
            '<div class="bg" @click="this.show=false"></div>' +
        '</div>',
        data: function () {
            return {
                tid: 0,
                show: !1,
                buy_money: 0,
                buy_contact:0,
                real_buy_money:0,
                think_money: 0,
                select_time: 0,
                select_good: "",
                other_money: "",
                btns: [],
                contact_btns:[],
                bl: 0,
                dir: 0,
                swl: 1,
                c_money: "休盘",
                type_name: null,
                code:null,
                norms:"",
                close_btn_str: "取消",
                buy_btn_str: "确定",
                info:"温馨提示：收盘时对于未成交订单将自动平仓,合约定金全额度返还",
                buy_btn_act: !1,
                ticket_list: null,
                ticket_index: null,
                ticket_number: 1,
                is_momney: !0,
                p_money: null,
                prompts: "",
                prompt_time: null,
                use_voucher:1,
                max_num:0,
                num:1,
                buy_btn_act_time:0
            }
        },
        events: {
            openbuy: function (t) {
                var i = this;
                loadshow(), postMsg("Index/checktrade", {
                    game_type: t.tid
                }, function (e) {
                    // i.buy_btn_act = !1, i.buy_btn_act_time = t.buy_btn_act_time, i.buy_btn_str = "距离下单时长还剩："+t.buy_btn_act_time+"秒"
                    loadhide(), i.buy_btn_act_time=0, e.Success ? t.buy_btn_act_time <= 0 ? (i.buy_btn_act = !0, i.buy_btn_str = "确定") : i.up_buy_btn_act_time(t.buy_btn_act_time) : (i.buy_btn_act = !1, i.buy_btn_str = "该产品还未开盘"),  i.data_init(t, e)
                });
            },
            money_change: function (t) {
                // console.log(this.code);
                this.show && (this.c_money = t[this.code][0], this.dir = t[this.code][1])
            },
            close: function (t) {
                this.show = !1
            },
            /*up_buy_btn_act_time:function (buy_btn_act_time) {
                var self = this;
                if (buy_btn_act_time > 0) {
                    // console.log(buy_btn_act_time);
                    self.buy_btn_act_time = buy_btn_act_time;
                    self.buy_btn_str = "距离下单时长还剩："+self.buy_btn_act_time+"秒";
                } else {
                    self.buy_btn_act = !0;
                    self.buy_btn_str = "确定";
                }
            }*/
        },
        methods: {
            up_buy_btn_act_time:function(buy_btn_act_time) {
                var self = this;
                self.buy_btn_act_time = buy_btn_act_time;
                if (self.buy_btn_act_time > 1) {
                    self.buy_btn_act = !1;
                    self.buy_btn_act_time--;
                    self.buy_btn_str = "距离下单时长还剩："+self.buy_btn_act_time+"秒";
                    if (self.buy_btn_act_time > -1) {
                        setTimeout(function () {
                            self.up_buy_btn_act_time(self.buy_btn_act_time)
                        }, 1000);
                    }
                } else {
                    self.buy_btn_act = !0;
                    self.buy_btn_str = "确定";
                }
            },
            data_init: function (t, v) {
                this.btns = t.btns.split(",").reverse(),this.contact_btns = t.contact_btns, this.max_num=t.max_num, this.buy_money = 10, this.use_voucher=1, this.select_time = t.select_time, this.select_good = t.select_good, this.swl = t.swl, this.bl = t.bl / 100, this.c_money = t.c_money, this.other_money = "", this.use_voucher=t.use_voucher, this.tid = t.tid, this.type_name = t.type_name, this.code=t.code, this.norms = t.norms, this.p_money = 100, this.is_momney = !0, this.ticket_index = null, this.ticket_list = null, this.select_money(100), this.get_ticket(v), this.select_contact(this.contact_btns[0].contact), this.show = !0
            },
            ticket_change: function (t) {
                this.ticket_number > t && (this.ticket_number = t), this.ticket_number && this.ticket_number < 1 && (this.ticket_number = 1), this.buy2_change()
            },
            prompt_hide: function () {
                this.prompts = ""
            },
            select_ticket: function (t) {
                var i = this.ticket_list[t];
                if (this.prompts = i.message + "", "" != this.prompt_hide && (this.prompt_time && clearTimeout(this.prompt_time), this.prompt_time = setTimeout(this.prompt_hide, 3e3)), 0 != i.can_user_num) {
                    if (this.ticket_index == t ? (this.ticket_index = null, this.is_momney = !0, this.buy_change(this.p_money)) : this.ticket_index = t, null != this.ticket_index) {
                        var e = this.ticket_list[this.ticket_index],
                            s = e.can_user_num;
                        this.ticket_number = s, this.is_momney && (this.p_money = this.buy_money), 2 != e.type ? (this.is_momney = !1, this.buy_change(e.money)) : (this.is_momney = !0, this.buy_change(this.p_money))
                    }
                    this.buy2_change()
                }
            },
            subtract: function () {
                this.num--;
                if (this.num < 1) {
                    this.num = 1;
                }
            },
            augment:function () {
                this.num++;
                if (this.num > this.max_num) {
                    this.num = this.max_num;
                }
            },
            get_ticket: function (v) {

                var t = this;
                if(t.use_voucher == 1) {
                    if(v.status=="ok") {
                        t.ticket_list = v.list
                    } else {
                        t.ticket_list=[];
                    }
                } else {
                    t.ticket_list=[];
                }
            },
            up_ticket:function () {
                if (null != this.ticket_list) {
                    for (var i=0; i<this.ticket_list.length; i++) {
                        /*if (this.ticket_list[i].use_money > this.buy_money && this.ticket_list[i].use_money > 0) {
                         this.ticket_list[i].can_user_num = 0;
                         this.ticket_list[i].message = '投资金额需要满足'+parseFloat(this.ticket_list[i].use_money).toFixed(2)+'元才能使用';
                         this.ticket_index = null;
                         } else {
                         this.ticket_list[i].can_user_num = 1;
                         this.ticket_list[i].message = '';
                         }*/
                        if (this.ticket_list[i].type == 2) {
                            if (this.ticket_list[i].use_money > this.buy_money && this.ticket_list[i].use_money > 0) {
                                this.ticket_list[i].can_user_num = 0;
                                this.ticket_list[i].message = '投资金额需要满足'+parseFloat(this.ticket_list[i].use_money).toFixed(2)+'元才能使用';
                                this.ticket_index = null;
                            } else {
                                this.ticket_list[i].can_user_num = 1;
                                this.ticket_list[i].message = '';
                            }
                        } else {
                            this.ticket_list[i].can_user_num = 1;
                            this.ticket_list[i].message = '';
                        }
                    }
                }
            },
            change: function (t) {
                var i = parseFloat(t.target.value);
                i && this.buy_change(i)
            },
            blur: function (t) {
                this.change(t), this.up_ticket(), this.buy2_change()
            },
            select_contact:function (t) {
                t = parseFloat(t), this.buy_contact = t
            },
            select_money: function (t) {
                t = parseFloat(t), this.buy_money = t, this.up_ticket(), this.buy2_change()
            },
            buy_change: function (t) {
                t = parseFloat(t), this.buy_money = t, this.buy2_change()
            },
            buy2_change: function () {
                if (this.think_money = this.buy_money + this.buy_money * this.bl, null != this.ticket_index) {
                    var t = this.ticket_list[this.ticket_index].type;
                    if (2 == t) {
                        var i = this.ticket_list[this.ticket_index].money;
                        // this.think_money = this.think_money + i * this.bl * this.ticket_number
                        this.think_money = this.think_money - i;
                        this.real_buy_money = this.buy_money - i;
                    } else {
                        var i = this.ticket_list[this.ticket_index].money;
                        this.think_money = this.think_money - i * this.ticket_number
                    }
                }
            },
            close: function () {
                this.buy_btn_act_time = -1;
                this.show = !1
            },
            define: function () {
                if (this.buy_btn_act) {
                    loadshow();
                    var t = this,
                        i = null,
                        n = null,
                        m = null;
                    null != this.ticket_index && (i = this.ticket_list[this.ticket_index].type, n = this.ticket_list[this.ticket_index].name, m = this.ticket_list[this.ticket_index].money), postMsg("Index/dealOrder", {
                        play_type: this.tid,
                        type: this.swl,
                        trade_time: this.select_time,
                        order_price: this.buy_money,
                        open_price: this.c_money,
                        order_contact:this.buy_contact,
                        play_name:this.type_name,
                        name_code:this.code,
                        norms:this.norms,
                        num:this.num,
                        juan_type: i,
                        juan_name: n,
                        juan_money: m,
                        can_use_juan_num: this.ticket_number
                    }, function (i) {
                        if (i.success==1) {
                            var order = {
                                user_id:i.user_id,
                                order_no:i.order_no,
                                code:t.code,
                                open_price:i.open_price,
                                type:t.swl,
                                order_contact:t.buy_contact
                            };
                            socket.emit('deal_order', order);

                            loadhide();
                            t.close();
                            layer.open({
                                content: i.msg ,skin: 'msg' ,time: 2 //2秒后自动关闭
                            });

                            var new_o = {
                                order_no:i.order_no,
                                type: t.swl,
                                open_price: i.open_price,
                                play_name:t.type_name,
                                num:t.num,
                                order_contact:t.buy_contact
                            };
                            t.$dispatch("new_order", {
                                order: new_o,
                                buy_act_time:i.buy_act_time
                            }),t.$dispatch("update_user_money", {
                                money: i.user_money
                            }), t.$dispatch("reduce_couponnumber", {
                                number: t.ticket_number
                            })
                        } else if (i.success == 0) {
                            loadhide();
                            layer.open({
                                content: i.msg
                                ,skin: 'msg'
                                ,time: 2 //2秒后自动关闭
                            });
                            // alertMsg(i.msg);
                        } else loadhide(), i.success==-1 ? alertMsg({
                            content: i.msg,
                            title: "提示",
                            btn: ["去充值", "取消"],
                            yes: function (t) {
                                location.href = "Pay/index"
                            }
                        }) : alertMsg(i.msg)
                    })
                }
            }
        }
    })
}]);